package com.zr.daoimpl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.DistributionRangePriceDaoLPN;

@Repository("DistributionRangePriceDaoLPN")
public class DistributionRangePriceDaoImplLPN extends BaseDaOImpl implements DistributionRangePriceDaoLPN{

	@Override
	public List getDistributionRangePrice(int page,int rows) {
		
		String hql = " select drp.drpId,drp.ordertype,drp.distributionscope,drp.drpFirstKilogramPrice,drp.drpNextKilogramPrice,drp.drpFirstCubicPrice,drp.drpNextCubicPrice,drp.drpRemarks,ds.dsName,dp.dpName,ot.otName  from Distributionrangeprice as drp,Distributionscope as ds,Deliverypoint  as dp,Ordertype  as ot where drp.dsId=ds.dsId and ds.dpId=dp.dpId and drp.otId=ot.otId";
		Query query = this.getCurrentSession().createQuery(hql);
		query.setFirstResult(page);
		query.setMaxResults((page-1)*rows);
		List list = query.list();
		return list;
	}

	@Override
	public int getDistributionRangePriceCount() {
		String hql = "select count(*) from distributionrangeprice  dr";
    	Query query = this.getCurrentSession().createQuery(hql);
    	int count = ((Number) query.uniqueResult()).intValue();
		return count;
	}

}
